package com.woniuxy.sddfp.common.utils;

import com.woniuxy.sddfp.common.constant.UserConstant;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @author yellow Doctor
 * @date 2025-06-24
 * @desc 蜗牛创想：www.woniuxy.com
 */
public class TokenUtils {


    /**
     * 拿到userId
     * @return
     */
    public static String getTokenUserId(){
        //RequestContextHolder.getRequestAttributes() 请求持有者 拿到请求属性
        //.getRequest() 拿到请求的 请求对象
        HttpServletRequest request= ((ServletRequestAttributes)
                RequestContextHolder.getRequestAttributes()).getRequest();
        String userId = request.getHeader(UserConstant.USERID);
        return  userId;
    }
}
